#ifndef NOSAL_EXEC_INTERNAL_EXEC_ARGUMENTS_H_
#define NOSAL_EXEC_INTERNAL_EXEC_ARGUMENTS_H_

#include <string>
#include <vector>

namespace netaos {
namespace nosal {
namespace exec {
namespace internal {

/// @brief Helper class for managing execution arguments.
///
/// The class collects/stores arguments and provides access to them in a form suitable
/// for POSIX exec-family finctinos.
class ExecArguments final
{
public:
    ExecArguments();
    explicit ExecArguments(size_t reserve);
    explicit ExecArguments(const std::vector<std::string>& arguments);
    ExecArguments(const ExecArguments& other);

    ExecArguments& operator=(const ExecArguments&) = delete;

    /// @brief AddArgument adds one argument to the internal collection
    ///
    /// @param argument the argument value
    void AddArgument(const std::string& argument);

    /// @brief Return NULL-terminated array of pointers to arguments.
    ///
    /// @note execv() should use it in this way: execv("", const_cast<char* const*>(GetArgv()));
    /// @note Any call for AddArgument() invalidates the earlier returned value.
    const char* const* GetArgv();

private:
    std::vector<std::string> arguments_;
    std::vector<const char*> argv_;
};

}  // namespace internal
}  // namespace exec
}  // namespace nosal
}  // namespace netaos

#endif  // NOSAL_EXEC_INTERNAL_EXEC_ARGUMENTS_H_
